﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace SpaceGame.Player
{
    public enum MissileType : byte
    {
        None = 0,
        Patriot = 1,
        Tomahawk = 2,
        Cruise = 3
    }

    public class Missile
    {
        private Texture2D m_MissileTexture;
        private MissileType m_MissileType;
        private float m_Speed = 0.02f;
        private float m_Rotation = 0.0f;
        private Vector2 m_Location;
        private Vector2 m_Velocity;
        private Vector2 m_Center;
        private bool m_IsAlive = true;

        public Texture2D MissileTexture
        {
            get { return m_MissileTexture; }
            set { m_MissileTexture = value; }
        }

        public bool IsAlive
        {
            get { return m_IsAlive; }
            set { m_IsAlive = value; }
        }

        public Vector2 Center
        {
            get { return m_Center; }
            set { m_Center = value; }
        }

        public Vector2 Velocity
        {
            get { return m_Velocity; }
            set { m_Velocity = value; }
        }
        
        public float Rotation
        {
            get { return m_Rotation; }
            set { m_Rotation = value; }
        }

        public Vector2 Location
        {
            get { return m_Location; }
            set { m_Location = value; }
        }

        public float Speed
        {
            get { return m_Speed; }
            set { m_Speed = value; }
        }

        public Missile(Texture2D texture, MissileType missileType, float rotation, Vector2 location)
        {
            m_Rotation = rotation;
            m_Speed = 0.2f;
            m_MissileTexture = texture;
            m_Center = new Vector2(m_MissileTexture.Width / 2, m_MissileTexture.Height / 2);
            m_Location = location;
            m_Velocity = new Vector2(
                (float)Math.Cos(rotation),
                (float)Math.Sin(rotation)) * 15.0f;
            m_MissileType = missileType;
        }
    }
}
